package com.fanhao.dllo.soundfm.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.fanhao.dllo.soundfm.R;

import java.util.List;

/**
 * Created by dllo on 16/1/11.
 */
public class CoolAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragmentList;
    private Context context;
    private String titles[] = {"推荐","主播","电台"};

    public CoolAdapter(FragmentManager fm,
                       Context context, List<Fragment> fragmentList ) {
        super(fm);
        this.context = context;
        this.fragmentList = fragmentList;
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return null;
    }

    // 为Tab设置布局
    public View getTabView(int position){
       View view = LayoutInflater.from(context)
               .inflate(R.layout.tab_veiw,null);
        TextView tv_tabs = (TextView) view.findViewById(R.id.tv_tabView);
        tv_tabs.setText(titles[position]);
        tv_tabs.setTextSize(17);
        return view;
    }
}
